package com.takeshequ.conversation;

import java.util.HashMap;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

import net.tsz.afinal.annotation.view.ViewInject;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.takeshequ.BasicActivity;
import com.takeshequ.R;
import com.takeshequ.friends.AddressBookContactsActivity;
import com.takeshequ.main.MainFragmentActivity;
import com.utils.HttpClientUtils;
import com.utils.HttpClientUtils.HttpResponseHandler;

public class DealWithAddFriendActivity extends BasicActivity {
	@ViewInject(id = R.id.dealwith_back, click = "back")
	private Button back;
	@ViewInject(id = R.id.dealwith_text)
	private TextView text;

	@ViewInject(id = R.id.dealwith_ok_btn, click = "ok")
	private ImageView okBtn;

	@ViewInject(id = R.id.dealwith_ok_btn, click = "cancel")
	private ImageView cancelBtn;
	private String textValue = "";
	private String mid = "";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dealwith_addfriend);
		textValue = getIntent().getStringExtra("text");
		mid = getIntent().getStringExtra("mid");

	}

	@Override
	protected void onResume() {
		super.onResume();
		text.setText(textValue);
	}

	public void ok(View view) {
		dealWithAddFriend("1");
	}

	public void cancel(View view) {
		dealWithAddFriend("0");
	}

	private void dealWithAddFriend(String result) {
		Map<String, String> params = new HashMap<String, String>();
		params.put("result", result);
		params.put("mid", mid);
		HttpClientUtils.post("dealAddfrindMessage", params,
				new HttpResponseHandler() {

					@Override
					public void handler(String response) {
					}
				});
		back(null);
	}

	public void back(View v) {
		overridePendingTransition(R.anim.push_left_in, R.anim.push_right_out);
		startActivity(new Intent(DealWithAddFriendActivity.this,
				MainFragmentActivity.class));
	}

}
